package com.chinaisafe.user.vo.response;

import com.chinaisafe.user.entity.SysTenant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * SysTenantRespVO
 * Description：租户响应值对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 10:22:08
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysTenantRespVO", description = "租户响应值对象")
public class SysTenantRespVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;


    @Schema(description = "名称")
    private String name;

    @Schema(description = "租户编码")
    private String code;

    @Schema(description = "简称")
    private String alias;

    @Schema(description = "统一信用代码")
    private String creditCode;

    @Schema(description = "上级租户")
    private Long parentId;

    @Schema(description = "上级租户名称")
    private String parentName;

    @Schema(description = "租户类型")
    private String type;

    @Schema(description = "系统运行日")
    private LocalDate useStartDate;

    @Schema(description = "租期")
    private LocalDate tenancyDate;

    @Schema(description = "是否启用")
    private Boolean enable;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "管理员id")
    private Long managerUserId;

    @Schema(description = "管理员名称")
    private String managerUserName;

    @Schema(description = "乐观锁版本")
    private Integer version;


    /**
     * 将实体类转换为响应值对象
     * @param entity 实体对象
     * @return SysTenantRespVO 响应值对象
     * @author xuefu.shu
     * @date 2024-07-12 10:22:08
     */
    public static SysTenantRespVO convertFromEntity(SysTenant entity) {
        SysTenantRespVO respVO = new SysTenantRespVO();
        respVO.id = entity.getId();
        respVO.version = entity.getVersion();
        // 给对应的字段赋值 可根据实际业务删减
        respVO.name = entity.getName();
        respVO.code = entity.getCode();
        respVO.alias = entity.getAlias();
        respVO.creditCode = entity.getCreditCode();
        respVO.parentId = entity.getParentId();
        respVO.type = entity.getType();
        respVO.useStartDate = entity.getUseStartDate();
        respVO.tenancyDate = entity.getTenancyDate();
        respVO.enable = entity.getEnable();
        respVO.remark = entity.getRemark();
        respVO.managerUserId = entity.getManagerUserId();
        return respVO;
    }
}
